/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package requestManager;

import java.awt.Component;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import lib.JButtonTable.ButtonEditor;

/**
 *
 * @author yoshi
 */
public class DisapproveButtonEditor extends ButtonEditor {

    public DisapproveButtonEditor(JCheckBox checkBox, final AbstractRequestManager myView) {
        super(checkBox);
        
        final DisapproveButtonEditor self = this;
        
        this.button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                new Thread() {

                    @Override
                    public void run() {
                        myView.getMyController().disapprove(((DisapproveButtonModel)self.getCellEditorValue()).getRequest());
                    }
                }.start();
            }
        });
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        button.setText(((DisapproveButtonModel) value).getText());
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    }

}
